Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2AudioManager = require("AudioManager");
var def_OPPO_VideoMgr = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this._rewardVideoAd = new Map();
    this._rewardcomplat = new Map();
    this._showerror = false;
  }
  return babel_createClass(_ctor, [{
    key: "Create",
    value: function Create(e, t) {
      var _this63 = this;
      this._rewardcomplat.set(e, t);
      var n = this;
      if (0 == this._rewardVideoAd.has(e)) {
        console.log("创建视频", e);
        var _t28 = window.qg.createRewardedVideoAd({
          adUnitId: e,
          multiton: true
        });
        _t28.onError(function (t) {
          console.log(t.errCode);
          $2AudioManager.AudioManager.getInstance().resumeAll();
          var _i16 = n._rewardcomplat.get(e);
          null != _i16 && _i16(t.errCode);
        });
        _t28.onClose(function (t) {
          console.log("视频关闭");
          $2AudioManager.AudioManager.getInstance().resumeAll();
          _this63._rewardVideoAd.get(e).showing = false;
          if (t && t.isEnded) {
            console.log("视频播放完毕", t);
            var _o59 = n._rewardcomplat.get(e);
            null != _o59 && _o59(true);
          } else {
            var _t29 = n._rewardcomplat.get(e);
            null != _t29 && _t29(false);
            console.log("中途退出");
          }
        });
        this._rewardVideoAd.set(e, _t28);
      }
    }
  }, {
    key: "destroy",
    value: function destroy(e) {
      if (this._rewardVideoAd.has(e)) {
        this._rewardVideoAd.get(e).destroy();
        this._rewardVideoAd.delete(e);
        this._rewardcomplat.delete(e);
      }
    }
  }, {
    key: "playvideo",
    value: function playvideo(e, t) {
      var _this64 = this;
      this.Create(e, t);
      this._rewardVideoAd.get(e).load().then(function () {
        _this64._rewardVideoAd.get(e).show().then(function () {
          $2AudioManager.AudioManager.getInstance().pauseAll();
        }).catch(function (e) {
          console.log("playvideo err:", e);
          $2AudioManager.AudioManager.getInstance().resumeAll();
        });
      }).catch(function (e) {
        console.log(e);
      });
    }
  }], [{
    key: "Instance",
    get() {
      _ctor._instance || (_ctor._instance = new _ctor());
      return _ctor._instance;
    }
  }]);
}();
exports.default = def_OPPO_VideoMgr;